<div ng-controller="Approval_LockOrderManageC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">审批详情</h1>
    </div>

    <div class="wrapper-md">
        <div class="panel panel-default">
            <div class="table-responsive">
                <form name="form" class="form-validation">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <span class="h4">锁价单详情</span>
                        </div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label>客户信息</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{dataLockOrder.Customer.ShortName}}--{{dataLockOrder.Customer.ShortName}}">
                            </div>
                            <div class="form-group">
                                <label>户头</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{dataLockOrder.Account.Name}}">
                            </div>
                            <div class="form-group">
                                <label>仓库</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{dataLockOrder.Provider.Name}}">
                            </div>
                            <div class="form-group">
                                <label style="margin-right: 10px;">是否标件</label>
                                <span ng-if="dataLockOrder.IsStandard">标件</span>
                                <span ng-if="!dataLockOrder.IsStandard">非标件</span>
                                <!--<label class="i-switch bg-info">
                                    <input type="checkbox" disabled="disabled" ng-model="dataLockOrder.IsStandard">
                                    <i></i>
                                </label>-->
                            </div>
                            <div class="form-group">
                                <label>订单类型：</label>
                                <label ng-if="dataLockOrder.OrderType == 0">普通订单</label>
                                <label ng-if="dataLockOrder.OrderType == 1">商品锁价</label>
                                <label ng-if="dataLockOrder.OrderType == 2">基价锁价</label>
                                <label ng-if="dataLockOrder.OrderType == 3">自采订单</label>
                            </div>
                            <div class="form-group">
                                <label>锁价金额：</label>
                                <label>{{dataLockOrder.Total | number:2}}</label>
                            </div>
                            <div class="form-group">
                                <label>每吨优惠合计：</label>
                                <label>{{dataLockOrder.UnitDiscount | number:2}}</label>
                            </div>
                             <div class="form-group">
                                <label>申请单价优惠：</label>
                                <label>{{-dataLockOrder.ApplyDiscount | number:2}}</label>
                            </div>
                            <div class="form-group">
                                <label>商品列表：</label>
                                <ul>
                                    <li>
                                        <label>名称</label>
                                        <label>材质</label>
                                        <label>规格</label>
                                        <label>/件重/</label>
                                        <label>[价格]</label><br>
                                    </li>
                                    <li ng-repeat="item in dataLockOrder.DepotCommodityRecords">
                                        <label>{{item.Commodity.Name}}</label>
                                        <label>{{item.Commodity.Standard}}</label>
                                        <label>{{item.Commodity.Format}}</label>
                                        <label>/{{item.Commodity.Weight}}/</label>
                                        <label>[{{item.Price | number:2}}]</label><br>
                                    </li>
                                </ul>
                            </div>
                            <div class="form-group">
                                <label>相关订单（创建时间/编号/总金额/状态）</label>
                                <ul>
                                    <li ng-repeat="item in dataLockOrder.Orders | orderBy:['CreateTime']">
                                        {{item.CreateTime}}/{{item.CodeNum}}/{{item.Total | number:2}}/
                                        <label ng-if="item.State == 0">待确认</label>
                                        <label ng-if="item.State == 1">驻厂确认</label>
                                        <label ng-if="item.State == 2">已发货</label>
                                        <label ng-if="item.State == 3">已收货</label>
                                        <label ng-if="item.State == 4">已结算</label>
                                        <label ng-if="item.State == 5">完结</label>
                                        <label ng-if="item.State == 6">取消</label>
                                        <label ng-if="item.State == 7">审核通过</label>
                                        <label ng-if="item.State == 8">已退货</label>
                                        <label ng-if="item.State == 9">已退款</label>
                                    </li>
                                </ul>
                            </div>
                            <div class="form-group">
                                <label>变更记录：</label>
                                <ul>
                                    <li ng-repeat="item in dataLockOrder.Records | orderBy:['CreateTime']">
                                        {{item.CreateTime}}/<label ng-if="item.Price != 0">{{item.Price | number:2}}/</label>{{item.Remarks}}
                                    </li>
                                </ul>
                            </div>
                            <div class="form-group">
                                <label>状态：</label>
                                <label ng-if="dataLockOrder.IsPause">已暂停</label>
                                <label ng-if="dataLockOrder.IsApproval">待审批</label>
                                <span ng-if="!dataLockOrder.IsApproval&&!dataLockOrder.IsPause">
                                    <label ng-if="dataLockOrder.ProcessState == 0">正常</label>
                                    <label ng-if="dataLockOrder.ProcessState == 1">议价</label>
                                    <label ng-if="dataLockOrder.ProcessState == 2">锁价</label>
                                    <label ng-if="dataLockOrder.ProcessState == 3">款项确认</label>
                                    <label ng-if="dataLockOrder.ProcessState == 4">完结</label>/
                                    <label ng-if="dataLockOrder.State == 0">待确认</label>
                                    <label ng-if="dataLockOrder.State == 1">驻厂确认</label>
                                    <label ng-if="dataLockOrder.State == 2">已发货</label>
                                    <label ng-if="dataLockOrder.State == 3">已收货</label>
                                    <label ng-if="dataLockOrder.State == 4">已结算</label>
                                    <label ng-if="dataLockOrder.State == 5">完结</label>
                                    <label ng-if="dataLockOrder.State == 6">取消</label>
                                    <label ng-if="dataLockOrder.State == 7">审核通过</label>
                                    <label ng-if="dataLockOrder.State == 8">已退货</label>
                                    <label ng-if="dataLockOrder.State == 9">已退款</label>
                                </span>
                            </div>
                        </div>
                        <div class="container-fluid">
                            <div class="row" style="border-bottom: red solid 1px" ng-repeat="item in orderdetaildata.CommodityInfos">
                                <div class="col-xs-12 col-md-12">
                                    <div>钢厂：{{item.ProviderCommodity.Commodity.Brand}}</div>
                                    <div>名称/材质/规格：{{item.ProviderCommodity.Commodity.Name}}/{{item.ProviderCommodity.Commodity.Standard}}/{{item.ProviderCommodity.Commodity.Format}}</div>
                                    <div>单价：{{item.Price | number:2}}/t</div>
                                    <div>数量：{{item.Count}}</div>
                                    <div>总质量：{{item.ProviderCommodity.Commodity.Weight | number:3}}t</div>
                                    <div>总价：{{item.Price | number:2}}*{{item.ProviderCommodity.Commodity.Weight | number:3}}t={{item.Price*item.ProviderCommodity.Commodity.Weight | number:2}}</div>
                                </div>
                            </div>
                        </div>
                        <div style="padding: 0px 15px">
                            <span><b>流程类型：</b>{{data.TypeName}}</span><br>
                            <span><b>内容：</b>{{data.Title}}</span><br>
                            <span><b>申请人：</b>{{data.Creater.Name}}</span><br>
                            <span><b>审批人：</b>{{data.NowApproverName}}</span><br>

                            <label><b>审批意见：</b></label>{{data.NowRemark}}<br>
                            <div ng-if="data.ApprovalState==1||data.ApprovalState==0">
                                <input ng-disabled="item.ApprovalState==2||item.ApprovalState==3" ng-model="data.opinion" type="text" class="form-control">
                                <button type="button" class="btn btn-success" ng-click="DoAppr(true)" ng-hide="item.ApprovalState==2||item.ApprovalState==3">通过</button>
                                <button type="button" class="btn btn-warning" ng-click="DoAppr(false)" ng-hide="item.ApprovalState==2||item.ApprovalState==3">驳回</button>
                                <button type="button" class="btn btn-default" ng-click="goorderList()">返回列表</button>
                                <span ng-show="item.ApprovalState==2">已通过</span>
                                <span ng-show="item.ApprovalState==3">已驳回</span>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    angular.module('app')
            .controller("Approval_LockOrderManageC", function($scope, $state, $http,$stateParams) {
                $http({
                    url: "/api/Approval?id=" + $stateParams.id,
                    method: "GET"
                    // data: { id: $stateParams.id}
                })
                        .then(function (res) {
                           
                            $scope.data = res.data;
                          
                            //获取员工数据方法
                                $http({
                                    url: "../api/LockOrder/Detail?id=" + $scope.data.Tag,
                                    method:"GET"
                                })
                                        .then(function (res) {
                                       
                                            $scope.dataLockOrder = res.data;
                                            console.log($scope.dataLockOrder);
                                        })
                                        .then(function (error) {
                                            if(error){
                                                console.log("error");
                                            }
                                        });
                        })
                        .then(function(error) {
                            if (error) {
                                alert("数据获取失败");
                            }
                        });

                //返回列表
                $scope.goorderList = function(){
                    $state.go('app.Approval_Index');
                };
                $scope.DoAppr= function(isOk) {
                    $http.post("/api/Approval/Approval?id=" + $stateParams.id + "&pass=" + isOk + "&opinion=" + $scope.data.opinion)
                            .success(function() {
                                alert("审批完成");
                                $scope.goorderList();
                            }).error(function() {alert("处理失败")})
                    ;
                }
            });

</script>